import request from "@/plugins/request";

var pre = "";
if (process.env.NODE_ENV !== "development") {
  pre = "/api/sa/eshop";
}

// 分页查询商品
export function searchPage(data) {
  return request({
    url: `${pre}/search/page`,
    method: "post",
    data,
  });
}

// 查询商品
export function queryGoods(data) {
  return request({
    url: `${pre}/search/get?goodsId=${data}`,
    method: "get",
  });
}

// 查询最新上架的top20商品
export function queryTopList(data) {
  return request({
    url: `${pre}/search/top20/list?goodsType=${data}`,
    method: "get",
  });
}

// 加入购物车
export function addCart(data) {
  return request({
    url: `${pre}/shopping-cart/add`,
    method: "post",
    data,
  });
}

// 查询购物车
export function queryCartList() {
  return request({
    url: `${pre}/shopping-cart/list`,
    method: "get",
  });
}

// 查询购物车数量
export function geCarNum() {
  return request({
    url: `${pre}/shopping-cart/counts`,
    method: "get",
  });
}

// 修改购物车商品数量
export function editCart(data) {
  return request({
    url: `${pre}/shopping-cart/edit`,
    method: "post",
    data,
  });
}

// 删除购物车
export function delCart(data) {
  return request({
    url: `${pre}/shopping-cart/del`,
    method: "post",
    data,
  });
}

// 收藏商品
export function goodSave(data) {
  return request({
    url: `${pre}/goods-fav/save?goodsId=${data}`,
    method: "post",
  });
}

// 查询我的商品收藏
export function goodFavPage(data) {
  return request({
    url: `${pre}/goods-fav/page`,
    method: "post",
    data,
  });
}

// 取消商品收藏
export function goodDelFav(data) {
  return request({
    url: `${pre}/goods-fav/del`,
    method: "post",
    data,
  });
}

// 校验当前登录人是否可购买本商品
export function queryValid(data) {
  return request({
    url: `${pre}/goods-scope/valid?goodsId=${data}`,
    method: "get",
  });
}
// 查询商品销售范围
export function queryRange(data) {
  return request({
    url: `${pre}/goods-scope/list?goodsId=${data}`,
    method: "get",
  });
}

// 保存商品销售范围
export function saveRange(data) {
  return request({
    url: `${pre}/goods-scope/save`,
    method: "post",
    data,
  });
}

// 发布商品信息
export function addGoods(data) {
  return request({
    url: `${pre}goods/save`,
    method: "post",
    data,
  });
}

// 上架商品
export function onShelf(data) {
  return request({
    url: `${pre}/goods/onshelf?goodsId=${data}`,
    method: "get",
  });
}

// 下架商品
export function offShelf(data) {
  return request({
    url: `${pre}/goods/offshelf?goodsId=${data}`,
    method: "get",
  });
}

// 查询商品详情
export function getShelf(data) {
  return request({
    url: `${pre}/goods/get?goodsId=${data}`,
    method: "get",
  });
}

// 删除商品
export function deleteShelf(data) {
  return request({
    url: `${pre}/goods/del`,
    method: "post",
    data,
  });
}

// 查询规格
export function queryWorkId(data) {
  return request({
    url: `${pre}/specconfig/list?networkId=${data}`,
    method: "get",
  });
}

// 查询规格值
export function queryConfigId(data) {
  return request({
    url: `${pre}/specconfig/attr/list?specConfigId=${data}`,
    method: "get",
  });
}

// 查询规格配置详情
export function querySpecs(data) {
  return request({
    url: `${pre}/specconfig/get?specConfigId=${data}`,
    method: "get",
  });
}

// 保存规格配置
export function saveSpecs(data) {
  return request({
    url: `${pre}/specconfig/save`,
    method: "post",
    data,
  });
}

// 删除规格配置
export function deleteSpecs(data) {
  return request({
    url: `${pre}/specconfig/del?specConfigId=${data}`,
    method: "post",
  });
}

// 查询供应商详情
export function querySupplier(data) {
  return request({
    url: `${pre}/supplier/get?supplierId=${data}`,
    method: "get",
  });
}

// 保存供应商
export function saveSupplier(data) {
  return request({
    url: `${pre}/supplier/save`,
    method: "post",
    data,
  });
}

// 删除供应商
export function deleteSupplier(data) {
  return request({
    url: `${pre}/supplier/del`,
    method: "post",
    data,
  });
}

// 查询商品分类详情
export function querySort(data) {
  return request({
    url: `${pre}/site-category/get?siteCategoryId=${data}`,
    method: "get",
  });
}

// 保存商品分类
export function saveSort(data) {
  return request({
    url: `${pre}/site-category/save`,
    method: "post",
    data,
  });
}

// 删除商品分类
export function deleteSort(data) {
  return request({
    url: `${pre}/site-category/del`,
    method: "post",
    data,
  });
}

// 查询销售网点详情
export function queryGetDeail(data) {
  return request({
    url: `${pre}/dealer-network/get?networkId=${data}`,
    method: "get",
  });
}

export function queryTable(data) {
  return request({
    url: `${pre}/dealer-network-admin/page`,
    method: "post",
    data,
  });
}

// 删除销售网点
export function deleteNetwork(data) {
  return request({
    url: `${pre}/dealer-network/del`,
    method: "post",
    data,
  });
}

// 保存销售网点
export function addSave(data) {
  return request({
    url: `${pre}/dealer-network/save`,
    method: "post",
    data,
  });
}

// 查询经销商详情
export function queryGetList(data) {
  return request({
    url: `${pre}/dealer/get?dealerId=${data}`,
    method: "get",
  });
}

// 删除经销商
export function deleteDealer(data) {
  return request({
    url: `${pre}/dealer/del`,
    method: "post",
    data,
  });
}

// 保存经销商
export function dealerSave(data) {
  return request({
    url: `${pre}/dealer/save`,
    method: "post",
    data,
  });
}

// 删除销售网点管理员
export function deleteAdmin(data) {
  return request({
    url: `${pre}/dealer-network-admin/del`,
    method: "post",
    data,
  });
}

// 保存销售网点管理员
export function saveAdmin(data) {
  return request({
    url: `${pre}/dealer-network-admin/save`,
    method: "post",
    data,
  });
}

// 根据多个网点标识查询网点配置
export function queryDealer(data) {
  return request({
    url: `${pre}/dealer-network-config/list`,
    method: "post",
    data,
  });
}
